<template>
  <div class="user_right fl ml20">
    <el-form
      :model="userInfo"
      status-icon
      :rules="rules"
      ref="userInfo"
      label-width="100px"
      class="userInfo"
    >
      <el-form-item label="操作员" prop="operator">
        <el-input class="uipt250" v-model="userInfo.operator"></el-input>
      </el-form-item>
      <el-form-item label="手机号" prop="mobile">
        <el-input
          class="uipt250"
          oninput="value=value.replace(/[^\d]/g,'')"
          onafterpaste="this.value=this.value.replace(/[^\d]/g,'') "
          v-model="userInfo.mobile"
        ></el-input>
      </el-form-item>
    </el-form>
    <div class="btn_userInfo">
      <div onselectstart="return false;" @click="submitUser('userInfo')">保存</div>
      <div onselectstart="return false;" @click="reset_trip">重置</div>
    </div>
  </div>
</template>

<script>
export default {
  data() {
    return {
      userInfo: {
        operator: "",
        mobile: ""
      },
      rules: {
        operator: [
          { required: true, message: "请填写操作员名字", trigger: "blur" }
        ],
        mobile: [{ required: true, message: "请填写手机号", trigger: "blur" }]
      }
    };
  },
  methods: {
    reset_trip() {
      for (let key in this.userInfo) {
        this.userInfo[key] = "";
      }
    },
    submitUser(formName) {
      this.$refs[formName].validate(valid => {
        if (valid) {
          alert("submit!");
        } else {
          console.log("error submit!!");
          return false;
        }
      });
    }
  }
};
</script>

<style lang="scss">
.userInfo {
  margin-top: 95px;
  .el-form-item__content {
    margin-bottom: 25px;
  }
  .el-form-item__label {
    font-size: 18px;
    width: 255px !important;
    &::after {
      content: ":";
      font-size: 18px;
      font-weight: 600;
      margin-left: 3px;
    }
  }
  .el-form-item__error {
    left: 195px;
  }
}
.uipt250 {
  width: 250px;
  margin-left: 40px;
  .el-input__inner {
    height: 32px;
  }
}
.btn_userInfo {
  display: flex;
  justify-content: center;
  margin-top: 146px;
  > div {
    width: 120px;
    height: 40px;
    text-align: center;
    line-height: 40px;
    border-radius: 5px;
    font-size: 18px;
    color: #fff;
    cursor: pointer;
    position: relative;
    transition: all 0.2s ease-in-out;
    &:nth-child(1) {
      background: #4448f8;
      margin-right: 25px;
      &:hover {
        background: #777acc9d;
      }
    }
    &:nth-child(2) {
      background: #e5e5e5;
      margin-left: 25px;
      &:hover {
        background: #5f5959;
      }
    }
  }
}
</style>